{% extends 'base_right.html' %}

{% block bodycontent %}
<div class="content">
    <form id="form" class="form-horizontal form-ajax" role="form" data-toggle="validator" method="POST" >{% csrf_token %}
        <input type="hidden" name="id" value="{{ id }}"/>
        <div class="form-group">
            <label for="name" class="control-label col-xs-12 col-sm-2">用户组名</label>
            <div class="col-xs-12 col-sm-6">
                <input type="text" class="form-control" id="name" name="row[name]" placeholder="用户组名" value="{{ name }}" data-rule="required" />
            </div>
        </div>
        
        <div class="form-group layer-footer">
            <label class="control-label col-xs-12 col-sm-2"></label>
            <div class="col-xs-12 col-sm-6">
                <a href="javascript:;" class="btn btn-success btn-embossed" >确定</a> 
                <button type="reset" class="btn btn-default btn-embossed">重置</button>
            </div>
        </div>

    </form>
</div>
{% endblock %}


{% block footer %}
<script>

    $('#form').validator({
        valid: function (ret) {
            var data = $("#form").serialize();
            apiAjax("/myauth/group/edit", data)
        }
    })
        // 使用链接代替submit按钮（注意：这种情况下输入框里面的回车键不能触发submit事件）
        .on("click", "a.btn.btn-success.btn-embossed", function (e) {
            $(e.delegateTarget).trigger("validate");
        });
</script>
{% endblock %}